Adventures in Pugs-land

Shlomi Fish on 2006-04-14T21:23:47

So I decided I'd like to write my first Perl 6 program, so I can see what's it like. So I downloaded and compiled Pugs and then started translating my solution to the Graham function quiz-of-the-week. to Perl 6.

So I started the translation. I first translated two small functions, and they did not work as expected. After I logged on to #perl6 on Freenode, and asked around it turned out it was a bug. This bug:

#!/usr/bin/pugs

use v6;

sub func()
{
my $d = [];
if (($d.elems() > 0) && ($d.[0] == 1))
{
return 0;
}
else
{
return $d;
}
}

say "func().perl == ", func().perl;

This function returned the array instead of 0, and I used a variant of it in my code. After noting it, Audrey Tang fixed it, and I was able to proceed.

Then I encountered another bug. :-). Eventually I got a commit access so I can put the bugs test files in the t/pugsbugs/ directory. I found two more bugs, until I finished writing my program. Surprisngly, most of these bugs were pretty basic, and I wonder how people didn't encounter them earlier.

Eventually, after I sorted the expressions' starting sigils, etc. and all the bugs were fixed in pugs, it worked. Sort of - it still had a horrible start-up time and was much slower than its perl5 program. But it worked.

Audrey told me to commit the converted program into the examples directory of pugs where the other quiz-of-the-week. Nothingmuch gave me a lot of commentary on how it can be made more perl6y when he reviewed the code on the channel, but I was too lazy to do anything about it, so I just commited it as is. Hopefully someone will hack on it further while it is inside the pugs repository.

So that's it - now back to perl 5 hacking.